//
//  FLMineViewController.m
//  FeeLing
//
//  Created by 乔光玉 on 2019/1/4.
//  Copyright © 2019年 大仙儿飘. All rights reserved.
//
#import "FLSameTableViewCell.h"
#import "FLMineViewController.h"
#import "FLConusViewController.h"
#import "FLSCentreViewController.h"
@interface FLMineViewController ()
<UITableViewDelegate, UITableViewDataSource,UINavigationControllerDelegate>
@property(nonatomic,strong)UITableView * personalTableView;
@end

@implementation FLMineViewController
-(void)backclick{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithHexString:@"#2B2D5C"];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    UIView *navview = [[UIView alloc] init];
    navview.frame = CGRectMake(0,0,SCREENWIDTH,64);
    
    navview.backgroundColor = [UIColor colorWithHexString:@"32346A"];
    [self.view addSubview:navview];
    UILabel *label = [[UILabel alloc] init];
    label.frame = CGRectMake(0,30,SCREENWIDTH,25);
    label.text = NSLocalizedString(@"mine", nil);
    label.font = [UIFont fontWithName:@"PingFangSC-Regular" size:18];
    label.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
    label.textAlignment = NSTextAlignmentCenter;
    label.alpha = 1;
    label.numberOfLines = 0;
    [self.view addSubview:label];
    
    UIButton * back = [UIButton new];
    [back setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    back.frame = CGRectMake(12, 27, 30, 30);
    [back addTarget:self action:@selector(backclick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:back];
   
    UIView * bottom =[[UIView alloc]initWithFrame:CGRectMake((SCREENWIDTH-255)/2, 84, 255, 255)];
    
    bottom.backgroundColor =[UIColor colorWithHexString:@"32346A"];
    bottom.clipsToBounds = YES;
    bottom.layer.cornerRadius = 255/2;
    [self.view addSubview:bottom];
    
    UIImageView * touxiang = [[UIImageView alloc]initWithFrame:CGRectMake((SCREENWIDTH-255)/2, 84, 255, 255)];
    [touxiang setImage:[UIImage imageNamed:@"我的头像"]];
    [self.view addSubview:touxiang];
    if (SCREENHEIGHT>800) {
        navview.frame = CGRectMake(0,0,SCREENWIDTH,64+20);
        label.frame = CGRectMake(0,30+20,SCREENWIDTH,25);
        back.frame = CGRectMake(12, 27+20, 30, 30);
        bottom.frame =CGRectMake((SCREENWIDTH-255)/2, 84+10, 255, 255);
        touxiang.frame =CGRectMake((SCREENWIDTH-255)/2, 97, 255, 255);
        bottom.frame =CGRectMake((SCREENWIDTH-255)/2, 97, 255, 255);
    }
    
    _personalTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,433-66, SCREENWIDTH, SCREENHEIGHT-367) style:UITableViewStylePlain];
    _personalTableView.dataSource = self;
    _personalTableView.delegate = self;
    _personalTableView.backgroundColor =  [UIColor colorWithHexString:@"#2B2D5C"];
     [_personalTableView setSeparatorColor:[UIColor clearColor]];
    _personalTableView.separatorStyle = UITableViewCellEditingStyleNone;
    [self.view addSubview:_personalTableView];
    
//    UIImageView * bottomimageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, SCREENHEIGHT-56, SCREENWIDTH, 56)];
//    [bottomimageview setImage:[UIImage imageNamed:@"我的背景"]];
//    [self.view addSubview:bottomimageview];
    
}
#pragma mark -- UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
   
        
        
        FLSameTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FLSameTableViewCell"];
    
        if (!cell) {
            cell = [[FLSameTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FLSameTableViewCell"];
            
            
        }
        
    
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (indexPath.row==0) {
           
            cell.titlelabel.text = NSLocalizedString(@"daoqishijian", nil);
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString * strDate = [ user objectForKey:@"strDate"];
            
            cell.timelabel.text =[self computeDateWithDays:7 fromDate:strDate];
            cell.timelabel.hidden = NO;
            cell.listImageView.hidden = YES;
            
            
        }else  if (indexPath.row==1) {
            
            cell.titlelabel.text = NSLocalizedString(@"guanyuwomen", nil);
            
            
        }else{
            cell.titlelabel.text = NSLocalizedString(@"lianxiwomen", nil);
            
        }
        
        
        
        
        
        
        return cell;
        
   
    
    
    
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
 return 66;
   
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
     [[NSNotificationCenter defaultCenter] postNotificationName:@"gerenpush"object:@(0)];
    if (indexPath.row==1) {
        self.hidesBottomBarWhenPushed=YES;
        FLSCentreViewController * vc = [[FLSCentreViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
        self.hidesBottomBarWhenPushed=NO;
        
        
    }else  if (indexPath.row==2){
        self.hidesBottomBarWhenPushed=YES;
        FLConusViewController * vc = [[FLConusViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
        self.hidesBottomBarWhenPushed=NO;
        
    }
    
    
}

//计算天数后的新日期
- (NSString *)computeDateWithDays:(NSInteger)days fromDate:(NSString *)fromDate
{
    NSDateFormatter *dateFormatter = [NSDateFormatter new];
    [dateFormatter setDateFormat:@"yyyy.MM.dd"];
    NSDate *myDate = [dateFormatter dateFromString:fromDate];
    NSDate *newDate = [myDate dateByAddingTimeInterval:60 * 60 * 24 * days];
    
    return [dateFormatter stringFromDate:newDate];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
